//
//  UserBestDataView.m
//  CoolTennisBall
//
//  Created by Coollang on 16/9/9.
//  Copyright © 2016年 CoolLang. All rights reserved.
//

#import "UserBestDataView.h"
#import "UserDataModel.h"
#import "NSString+Extension.h"

@interface UserBestDataView ()
@property (weak, nonatomic) IBOutlet UILabel *bestNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *bestNumLabel;
@property (weak, nonatomic) IBOutlet UILabel *unitLabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *nameLabWidthCon;

@end

@implementation UserBestDataView

- (void)awakeFromNib {
    [super awakeFromNib];
    BOOL isChinese = [NSBundle currentLanguageIsChinese];
    NSString *serveStr = isChinese ? @"发球速度" : @"Serve Speed";
    CGSize size = [serveStr textSizeWithtextMaxSize:CGSizeMake(MAXFLOAT, MAXFLOAT) font:[UIFont systemFontOfSize:14]];
    
    if (kYFScreenWidth < 375) {
        if (isChinese) {
            self.nameLabWidthCon.constant = size.width + 20;
        }else {
            self.nameLabWidthCon.constant = size.width + 10;
        }
    }else {
        if (isChinese) {
            self.nameLabWidthCon.constant = size.width + kAutoWid(30);
        }else {
            self.nameLabWidthCon.constant = size.width + kAutoWid(40);
        }
    }
}

- (void)configerWithBestModel:(UserBestDataModel *)bestDataModel {
    
    self.bestNameLabel.text = bestDataModel.bestDataName;
    self.bestNumLabel.text = bestDataModel.bestValueStr;
    
    self.unitLabel.text = bestDataModel.unitString;
}

+ (instancetype)userBestDataView {
   return [[NSBundle mainBundle] loadNibNamed:@"UserBestDataView" owner:nil options:nil].firstObject;
}

@end
